import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'CreditAccountDetailM',
  state: {},
  effects: {
    //查询信用账户资金明细列表
    *queryTableList({ payload, callback }, { call, put }) {
      const res = yield call(api.creditAccountDetail.queryTableList, payload);
      if (res && res.code == 0) {
        let temp = res.data || {};
        callback(temp);
      } else {
        callback();
        message.error(res ? res.msg || '查询资金明细失败！' : '查询资金明细失败！');
      }
    },
    //查询保证金明细
    *queryMarginMoneyList({ payload, callback }, { call, put }) {
      const res = yield call(api.creditAccountDetail.queryMarginMoneyList, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        callback();
        message.error(res ? res.msg || '查询当前保证金占用明细失败' : '查询当前保证金占用明细失败');
      }
    },

    reducers: {
      save(state, { payload }) {
        return {
          ...state,
          ...payload,
        };
      },
    },
  },
};
